package model

import (
	"time"
)

// FileMonitorRecord 文件监控记录
type FileMonitorRecord struct {
	ID           string    `json:"id" db:"id"`
	DirectoryID  string    `json:"directory_id" db:"directory_id"`
	FilePath     string    `json:"file_path" db:"file_path"`
	FileName     string    `json:"file_name" db:"file_name"`
	FileSize     int64     `json:"file_size" db:"file_size"`
	FileModTime  time.Time `json:"file_mod_time" db:"file_mod_time"`
	FileHash     string    `json:"file_hash" db:"file_hash"`
	IsIndexed    bool      `json:"is_indexed" db:"is_indexed"`
	IndexedAt    time.Time `json:"indexed_at" db:"indexed_at"`
	CreatedAt    time.Time `json:"created_at" db:"created_at"`
	UpdatedAt    time.Time `json:"updated_at" db:"updated_at"`
}

// DirectoryMonitorRecord 目录监控记录
type DirectoryMonitorRecord struct {
	ID              string    `json:"id" db:"id"`
	DirectoryPath   string    `json:"directory_path" db:"directory_path"`
	DirectoryName   string    `json:"directory_name" db:"directory_name"`
	CollectionName  string    `json:"collection_name" db:"collection_name"`
	IsMonitoring    bool      `json:"is_monitoring" db:"is_monitoring"`
	LastScanTime    time.Time `json:"last_scan_time" db:"last_scan_time"`
	LastIndexedTime time.Time `json:"last_indexed_time" db:"last_indexed_time"`
	TotalFiles      int       `json:"total_files" db:"total_files"`
	IndexedFiles    int       `json:"indexed_files" db:"indexed_files"`
	CreatedAt       time.Time `json:"created_at" db:"created_at"`
	UpdatedAt       time.Time `json:"updated_at" db:"updated_at"`
}

// FileChangeType 文件变更类型
type FileChangeType string

const (
	FileChangeAdded   FileChangeType = "added"
	FileChangeModified FileChangeType = "modified"
	FileChangeDeleted FileChangeType = "deleted"
)

// FileMonitorChange 文件变更记录
type FileMonitorChange struct {
	ID           string        `json:"id"`
	DirectoryID  string        `json:"directory_id"`
	FilePath     string        `json:"file_path"`
	ChangeType   FileChangeType `json:"change_type"`
	OldSize      int64         `json:"old_size,omitempty"`
	NewSize      int64         `json:"new_size,omitempty"`
	OldModTime   time.Time     `json:"old_mod_time,omitempty"`
	NewModTime   time.Time     `json:"new_mod_time,omitempty"`
	OldHash      string        `json:"old_hash,omitempty"`
	NewHash      string        `json:"new_hash,omitempty"`
	Processed    bool          `json:"processed"`
	ProcessedAt  time.Time     `json:"processed_at,omitempty"`
	CreatedAt    time.Time     `json:"created_at"`
}

// DirectoryHashInfo 目录哈希信息
type DirectoryHashInfo struct {
	DirectoryID string            `json:"directory_id"`
	FilePaths   map[string]string `json:"file_paths"` // 文件路径到哈希的映射
	Version     int               `json:"version"`    // 版本号，用于检测变更
	UpdatedAt   time.Time         `json:"updated_at"`
}